package Cmd

import (
	"Volta/Core"
	"fmt"
	"github.com/spf13/cobra"
	"os"
)

var cfgFile string
var service string
var name string
var RootCmd = &cobra.Command{
	Use:   "Volta",
	Short: "Leon Volta",
	Long: `Leon Volta`,
	Run: func(cmd *cobra.Command, args []string) {
		if len(name) == 0 {
			cmd.Help()
			return
		}
		Core.Kernel.ConfigFile = cfgFile

		Core.Kernel.Service = service

		Core.Kernel.CoreRegister()
	},
}

func Volta() {
	if err := RootCmd.Execute(); err != nil {
		fmt.Println(err)
		os.Exit(-1)
	}
}

func init() {
	RootCmd.Flags().StringVarP(&cfgFile,"config","c","env.yaml","config file (default is env.yaml)")
	RootCmd.Flags().StringVarP(&service,"service","s","all","service type (default is all)")
	RootCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
	RootCmd.Flags().StringVarP(&name, "name", "n", "coral", "person's name")
}
